<%@page import="com.labot.webapp.action.messages.TextMessagesType"%>
<%@page import="org.directwebremoting.WebContextFactory"%>
<%@page import="com.labot.webapp.listener.StartupListener"%>
<%@page import="com.labot.types.AuditType"%>
<%@ include file="/common/taglibs.jsp" %>

<head>
    <title><fmt:message key="auditList.title"/></title>
    <meta name="menu" content="AdminMenu"/>
    <script type="text/javascript" src="<c:url value='/dwr/interface/DwrService.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/dwr/engine.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/dwr/util.js'/>"></script>
</head>
<body id="auditList">

<div>
    <h2><fmt:message key="auditList.heading"/></h2>

    <p><fmt:message key="auditList.message"/></p>


	<div >
	<s:form name="audit" action="audit" method="post" autocomplete="off">
		<div class="filter">
	        <s:textfield key="from"  />
	        <s:textfield key="to"  />
			<fieldset>
	            <label for="auditType"><fmt:message key="audit.auditType"/></label>
	            <select id="auditType" name="auditType">
	            	<option value="null" ${fn:contains(auditType, type) ? 'selected' : ''}><fmt:message key="auditType.ALL"/></option>
	                <c:forEach items="<%= AuditType.values() %>" var="type">
	               	 	<option value="${type}" ${fn:contains(auditType, type) ? 'selected' : ''}><fmt:message key="auditType.${type}"/></option>
	                </c:forEach>
	             </select>
	        </fieldset>
	        <s:textfield key="event"  />
	        <s:textfield key="username"  />
	        <s:textfield key="executionPlace"  />
		</div>
        <div class="actionsfilter">
        	<s:submit type="button" cssClass="btn btn-primary" method="list" key="button.filter" theme="simple" >
                <i class="icon-ok icon-white"></i>
                <fmt:message key="button.filter"/>
            </s:submit>
	    	<a class="btn" href="${ctx}/admin/audit" >
	            <i class="icon-remove"></i> <fmt:message key="button.clear"/>
	        </a>
        </div>

    </s:form>
	</div>


    <display:table name="auditList" id="auditList" cellspacing="0" cellpadding="0"
                   class="table table-condensed table-striped table-hover" pagesize="300" requestURI="">
 		<display:column style="width: 24px">
 			<c:if test="${ auditList.auditType eq 'INFO'            }"><img class="icon" src="${ ctx }/images/msg-info.png"      alt="${ auditList.auditType }"/></c:if>
 			<c:if test="${ auditList.auditType eq 'WARNING'         }"><img class="icon" src="${ ctx }/images/msg-warning.png"   alt="${ auditList.auditType }"/></c:if>
 			<c:if test="${ auditList.auditType eq 'ERROR'           }"><img class="icon" src="${ ctx }/images/msg-error.png"     alt="${ auditList.auditType }"/></c:if>
 			<c:if test="${ auditList.auditType eq 'EXCEPTION_ERROR' }"><img class="icon" src="${ ctx }/images/msg-exception.png" alt="${ auditList.auditType }"/></c:if>
 		</display:column>
        <display:column property="time" format="{0,date,dd/MMM/yyyy hh:mm aa}" style="width: 120px; font-size:0.8em;" />
 		<display:column property="event" style="width: 50px; font-size:0.8em;" />
 		<display:column property="userName" style="width: 50px; font-size:0.8em;" />
 		<display:column style="font-size:0.8em;" titleKey="audit.excecutionPlace">
 		    <img class="plus" width="14px" src="${ ctx }/images/plus.png"
 		    	 onclick="toogleInfo('info_${ auditList.id }')" />
 		    ${ auditList.executionPlace } 
 		    <div id="info_${ auditList.id }" style="display: none; ">
 		        <pre style="font-size:0.9em;">${ auditList.raw }</pre>
 		    </div>
 		</display:column>
    </display:table>
 
</div>

<script type="text/javascript">
	$('#audit_from').datetimepicker({timeFormat: 'HH:mm:ss'});
	$('#audit_to').datetimepicker({timeFormat: 'HH:mm:ss'});

	function toogleInfo(id) {
		$('#'+id).toggle("fast");
	}

</script>
</body>